﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using ManagementSystem.DataSet1TableAdapters;

namespace ManagementSystem
{
    /// <summary>
    /// Hinnete aken, mis kuvab õpilased ja nende hinded.
    /// </summary>
    public partial class Hinded : Window
    {

        DataSet1 dataset;
        HinneTableAdapter adapter;

        /// <summary>
        /// Konstruktor
        /// </summary>
        public Hinded()
        {
            InitializeComponent();
            dataset = new DataSet1();
            adapter = new HinneTableAdapter();
            adapter.Fill(dataset.Hinne);

            dataset.Hinne.HinneRowChanged +=
        new DataSet1.HinneRowChangeEventHandler(HinneRowModified);
    dataset.Hinne.HinneRowDeleted +=
        new DataSet1.HinneRowChangeEventHandler(HinneRowModified);



            this.DataContext = dataset.Hinne.DefaultView;       
            
        }

        /// <summary>
        /// Kui muudetakse rea kastide väärtusi.
        /// </summary>
        /// <param name="sender">Sender objekt</param>
        /// <param name="e">Sündmuse parameetrid</param>
        void HinneRowModified(object sender, DataSet1.HinneRowChangeEvent e)
        {
            try
            {
                


                adapter.Update(dataset.Hinne);
            }
            catch (Exception)
            {

            }
        }

        
        
    }
}
